Skip to content

London Class 9 - Farzaneh Haghani - Node - Class work#19

Open
farzaneh-haghani wants to merge 3 commits intoCodeYourFuture:masterfrom
farzaneh-haghani:master
Open

London Class 9 - Farzaneh Haghani - Node - Class work#19
farzaneh-haghani wants to merge 3 commits intoCodeYourFuture:masterfrom
farzaneh-haghani:master

Conversation

@farzaneh-haghani
Copy link

No description provided.

Copy link
Member

@JDysiewicz JDysiewicz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor error handling changes, but overall really nice work!!

Comment on lines +24 to +25
const amount = req.query.amount;
res.status(200).json(`You asked for ${amount} chocolate!`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would you handle the case where amount wasn't passed in as a query param?

Comment on lines +46 to +50
albums.forEach((album, index) => {
if (album.albumId === req.params.id) {
albums.splice(index, 1);
res.status(200).json("Deleted");
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could add an else case here which returns a 404 status

})
});

app.listen(3000, () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually we'd define the port as an environment variable and give it a default value, e.g. const PORT = process.env.PORT ?? 3000, app.listen(PORT, ...) - this makes it easier to deploy when you come around to doing that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants